package com.quanyan.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * DynamicProxy
 *
 * @author Tu Chun
 * @date 2017/1/3
 */
public class DynamicProxy implements InvocationHandler {
   private Object subobject;

    public DynamicProxy(Subject subobject) {
        this.subobject=subobject;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("before rend house");
        System.out.println("Method:" + method);
        Object result=method.invoke(subobject, args);
        System.out.println("after rent house");
        return result;
    }
}
